<template>
  <div class="app-container home">

    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>下载小程序码(桌号)</h2>
        <div style="width: 100%;display: flex;"> <el-input v-model="tableId" placeholder="请输入桌号" type="number" style="margin-right: 10px;"></el-input>

         <el-input v-model="size" placeholder="请输入小程序码的尺寸" type="number"></el-input>
<el-button type="primary" style="margin-left: 10px;" @click="toDownload">下载</el-button>
         </div>

      </el-col>


    </el-row>


  </div>
</template>

<script>
  import { download } from "@/api/system/config";
export default {
  name: "Index",
  data() {
    return {
      // 版本号
      version: "1.0",
      tableId:null,
      size:null
    };
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    toDownload(){
      download({
        "tableId":this.tableId,
        "width":this.size
      }).then((res)=>{

        console.log(res)
        const name = res.headers['download-filename'];
          const blob=new Blob([res.data])
          const url=window.URL.createObjectURL(blob)
          const link=document.createElement('a')
          link.href=url;
          link.setAttribute('download',name)
          document.body.append(link)
          link.click()
      })


    },
  }
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

